var api = require('../../utils/api.js')
var app = getApp()
Page({
    data: {
        info:[],
        openid:''
    },

    onLoad() {
        var that=this;
        api.post({
            url: 'index/getpublicinfo',
            data: {},
            success: data => {
                that.setData({
                    info:data.data
                })
            }
        })

    },
    onShow(){
        //调用登录接口
    },

    getnumbner: function(e){
        console.log(e.detail.value);
        var number=e.detail.value;
        this.setData({
            number:number
        })
       
    },
    getpassw: function(e){
        console.log(e.detail.value);
        var number=e.detail.value;
        this.setData({
            passw:number
        })
       
    },

    logins(){

        var number=this.data.number;
        var passw=this.data.passw;

        var that=this;
        api.post({
            url: 'user/login',
            data: {account:number,password:passw},
            success: data => {
                console.log(data);
                wx.showToast({
                  title: data.msg,
                  icon:'none'
                })

                if(data.code==1){
                    wx.setStorageSync('userinfo', data.data.userinfo);
                    wx.setStorageSync('token', data.data.userinfo.token);

                    wx.switchTab({
                      url: '/pages/my/my',
                    })

                }

            }
        })

    }

})
